package com.dstation.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description: 配置授权拦截器
 * @author Eastward
 * @date 2022/4/19 - 9:40
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    //配置默认访问页面
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/user/index");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String path = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\images\\";
        registry.addResourceHandler("/userIcon/**").addResourceLocations("file:"+path+"userIcon\\");
        registry.addResourceHandler("/dynImages/**").addResourceLocations("file:"+path+"dynImages\\");
    }
}
